package com.corhyfar.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.corhyfar.beans.ClienteTemporalDTO;
import com.corhyfar.service.ClienteTemporalService;
import com.corhyfar.service.impl.ClienteTemporalServiceImpl;

/**
 * Servlet implementation class Solicitud
 */
@WebServlet("/Solicitud")
public class Solicitud extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public Solicitud() {
		super();
		// TODO Auto-generated constructor stub
	}

	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		procesar(request, response);
	}

	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		procesar(request, response);

	}

	private void procesar(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		ClienteTemporalService clienteTemporalService = new ClienteTemporalServiceImpl();

		String nombreClienteTemp = request.getParameter("nombre");
		String apellidoPaternoClienteTemp = request
				.getParameter("Apellido_Paterno");
		String apellidoMaternoClienteTemp = request
				.getParameter("Apellido_Materno");
		String telefonoClienteTemp = request.getParameter("telefono");
		String emailClienteTemp = request.getParameter("email");
		String empresaClienteTemp = request.getParameter("empresa");
		String mensajeClienteTemp = request.getParameter("mensaje");

		ClienteTemporalDTO temporalDTO = new ClienteTemporalDTO(
				nombreClienteTemp, apellidoPaternoClienteTemp,
				apellidoMaternoClienteTemp, telefonoClienteTemp,
				empresaClienteTemp, emailClienteTemp, mensajeClienteTemp);

		clienteTemporalService.ingresaClienteTemporal(temporalDTO);

		request.getRequestDispatcher("/Corhyfar_AreaUsuario - Solicitud.jsp")
				.forward(request, response);

	}

}
